package com.popeye.demo.angular.web.controller;


import com.popeye.demo.angular.web.AppConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("home")
public class HomeController {

    @Autowired
    private AppConfig appConfig;

    @GetMapping("/info")
    public Map<String, String> appInfo() {
        final Map<String, String> info = new HashMap<>();
        info.putAll(appConfig.getAppInfo());
        info.put("timestamp", LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME));
        return info;
    }

}
